﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using UnliQ.Core;
using UnliQ.Data;

namespace UnliQ.ServiceLayer
{
    public class UnliQContext
    {
        private UnliQContext() { }

        #region Private Members
        private static UnliQContext _currentContext = null;
        private static object _contextLock = new object();

        private IQueueRepo _queueRepo = null;
        private IUsersRepo _usersRepo = null;

        #endregion


        public static UnliQContext Current
        {
            get
            {
                lock (_contextLock)
                {
                    if (_currentContext == null) _currentContext = new UnliQContext();
                }
                return _currentContext;
            }
        }

        public IQueueRepo QueueRepo { get { if (_queueRepo == null)  _queueRepo = ProviderFactory.CreateProvider<IQueueRepo>(); return _queueRepo; } }
        public IUsersRepo UsersRepo { get { if (_usersRepo == null) _usersRepo = ProviderFactory.CreateProvider<IUsersRepo>(); return _usersRepo; } }
    }
}
